package com.macro.mall.converter;

import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.property.ExcelContentProperty;

public class TourismPConverter implements Converter<String> {

    @Override
    public CellDataTypeEnum supportExcelTypeKey() {
        return CellDataTypeEnum.STRING;
    }

    @Override
    public String convertToJavaData(CellData cellData, ExcelContentProperty excelContentProperty, GlobalConfiguration globalConfiguration) throws Exception {
        return cellData.getStringValue();
    }

    @Override
    public CellData<String> convertToExcelData(String value, ExcelContentProperty excelContentProperty, GlobalConfiguration globalConfiguration) throws Exception {
        String result;
        switch (value) {
            case "0":
                result = "已预约";
                break;
            case "1":
                result = "已乘车";
                break;
            case "2":
                result = "已失效";
                break;
            case "3":
                result = "已取消";
                break;
            default:
                result = "未知";
        }
        return new CellData<>(result); // 返回转换后的Excel单元格数据
    }

    @Override
    public Class<String> supportJavaTypeKey() {
        return String.class; // 表示该转换器支持的Java类型为String类型
    }
}
